<?php

class foreground {
	public $db, $memberinfo, $isLogin;
	private $_member_modelinfo;
	
	public function __construct() {
		self::check_ip();
		$this->db = pc_base::load_model('member_model');
		self::check_member();
		
		$this->dbContent = pc_base::load_model("mybasecontent_model");
		$this->dbType = pc_base::load_model("myassorttype_model");
		$this->dbLink = pc_base::load_model("mylink_model");
		
		
		$whereSql = " is_show = 1";
		$orderSql = " show_index ASC,id DESC";
		$nav = $this->dbType->select($whereSql,'*','',$orderSql);
		
		$this->nav = array(
		// 			'0'=>array('name'=>'首页','url'=>'/index.php?m=hchabout&c=index&a=init'),
				'1'=>array('name'=>'关于华创','url'=>'/index.php?m=hchabout&c=index&a=init'),
				'2'=>array('name'=>'创业故事','url'=>'/index.php?m=hchstory&c=index&a=init'),
				'3'=>array('name'=>'企业服务','url'=>'/index.php?m=hchservice&c=index&a=init'),
				'4'=>array('name'=>'浏览项目','url'=>'/index.php?m=hchbrowse&c=index&a=imageList'),
				'5'=>array('name'=>'人才对接','url'=>'/index.php?m=hchhr&c=index&a=init')
		);
		
		$whereSql = " name = 'roundimg'";
		$roundimgTypeId = $this->dbType->get_one($whereSql,'id');
		$whereSql = array('assort_type_id'=>$roundimgTypeId['id'],'is_del'=>0);
		$orderSql = " id DESC";
		$this->imgList = $this->dbContent->select($whereSql,'*','',$orderSql);
		
		$whereSql = " is_del = 0";
		$this->linkList = $this->dbLink->select($whereSql,'*','',$orderSql);
		
	}
	

	public function browse(){
		$id = $_GET['id'];
		$browse = $_GET['br'];
		$item['browse_times'] = $browse + 1;
		$this->db->update($item,$where = 'id = "'.$id.'"');
	
	
		echo $item['browse_times'];
	}
	
	
	/**
	 * 判断用户是否已经登陆
	 */
	final public function check_member() {
		$this->isLogin = false;
		$userid = param::get_cookie('_userid');
		$password = param::get_cookie('_password');
		if(!empty($userid)){
			$this->memberinfo = $this->db->get_one(array('userid'=>$userid));
			if($this->memberinfo && $this->memberinfo['password'] === $password) {
				$this->isLogin = true;
			}
		}
	}
	/**
	 * 
	 * IP禁止判断 ...
	 */
	final private function check_ip(){
		$this->ipbanned = pc_base::load_model('ipbanned_model');
		$this->ipbanned->check_ip();
 	}
	
}